package work.cqhx.springapi.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import work.cqhx.springapi.pojo.Teacher;
import work.cqhx.springapi.returnjson.ReturnJson;
import work.cqhx.springapi.service.TeacherService;

import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/api/teacher")
public class TeacherController {
    @Autowired
    private TeacherService teacherService;

    @GetMapping("/login")
    public ReturnJson query(@RequestParam("name") String name, @RequestParam("password")String password){
        ReturnJson returnJson = new ReturnJson();
        if(name != null && password != null){
            if(teacherService.queryTeacher(name,password)){
                returnJson.setStatus(true);
                returnJson.setMessage("http://api.cqhx.work/studentManagement");

                return returnJson;
            }
        }
        returnJson.setStatus(false);
        returnJson.setMessage("用户名或密码错误");
        return returnJson;
    }
}
